package com.leetcode.algorithm.y22.m06;

import java.util.Arrays;

/**
 * 1502. 判断能否形成等差数列
 * 
 * https://leetcode.cn/problems/can-make-arithmetic-progression-from-sequence/
 * 
 * @author jie.deng
 *
 */
class Question1502Solution01 {
	
	public boolean canMakeArithmeticProgression(int[] arr) {
		Arrays.sort(arr);
		int diff = arr[1] - arr[0];
		for (int i = 1; i < arr.length - 1; i++) {
			if (arr[i + 1] - arr[i] != diff) {
				return false;
			}
		}
		return true;
	}
    
}